package com.base.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.base.mapper.EmpiWeightConfigMapper;
import com.base.service.EmpiWeightConfigService;
import com.base.utils.CombinationUtil;
import com.base.vo.EmpiAlgorithmConfig;
import com.base.vo.EmpiWeightConfig;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.io.Serializable;
import java.util.List;

/**
 *
 */
@Service
public class EmpiWeightConfigServiceImpl extends ServiceImpl<EmpiWeightConfigMapper, EmpiWeightConfig>
implements EmpiWeightConfigService{

    @Override
    public List<EmpiWeightConfig> list() {
        return this.baseMapper.selectList();
    }

    /**
     * 获取满足权重的字段组合列表
     *
     * @param id
     * @return
     */
    @Override
    public List<List<EmpiAlgorithmConfig>> listByWeight(Serializable id) {
        EmpiWeightConfig empiWeightConfig = this.baseMapper.selectById(id);
        Assert.notNull(empiWeightConfig,"根据主键未找到EmpiWeightConfig对象，请检查");
        List<EmpiAlgorithmConfig> algorithmConfigList = empiWeightConfig.getAlgorithmConfigList();
        CombinationUtil combinationUtil = new CombinationUtil(algorithmConfigList, "weight", empiWeightConfig.getSeemWeight());
        return combinationUtil.combinationSum();
    }
}




